home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / RCS / Mem_PrintConfig.c,v < prev    next >
Encoding:
Text File  |  1991-12-03  |  3.7 KB  |  165 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.2.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     89.01.30.15.39.35;  author brent;  state Exp;
  11. branches 1.2.1.1;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     88.05.20.15.49.21;  author ouster;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19. 1.2.1.1
  20. date     91.12.02.20.37.36;  author kupfer;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 1.2
  30. log
  31. @Fixed these trace routines to print out the correct bucket sizes
  32. @
  33. text
  34. @/* 
  35.  * Mem_PrintConfig.c --
  36.  *
  37.  *    Source code for the "Mem_PrintConfig" library procedure.  See memInt.h
  38.  *    for overall information about how the allocator works..
  39.  *
  40.  * Copyright 1988 Regents of the University of California
  41.  * Permission to use, copy, modify, and distribute this
  42.  * software and its documentation for any purpose and without
  43.  * fee is hereby granted, provided that the above copyright
  44.  * notice appear in all copies.  The University of California
  45.  * makes no representations about the suitability of this
  46.  * software for any purpose.  It is provided "as is" without
  47.  * express or implied warranty.
  48.  */
  49.  
  50. #ifndef lint
  51. static char rcsid[] = "$Header: Mem_PrintConfig.c,v 1.1 88/05/20 15:49:21 ouster Exp $ SPRITE (Berkeley)";
  52. #endif not lint
  53.  
  54. #include "memInt.h"
  55.  
  56. /*
  57.  * ----------------------------------------------------------------------------
  58.  *
  59.  * Mem_PrintConfig --
  60.  *
  61.  *    Prints out the exact configuration of the dynamic memory allocator
  62.  *    using the default printing routine.
  63.  *
  64.  * Results:
  65.  *      None.
  66.  *
  67.  * Side effects:
  68.  *      Stuff gets printed.
  69.  *
  70.  * ----------------------------------------------------------------------------
  71.  */
  72.  
  73. ENTRY void
  74. Mem_PrintConfig()
  75. {
  76.     register Address ptr;
  77.     int i, j;
  78.  
  79.     LOCK_MONITOR;
  80.  
  81.     if (!memInitialized) {
  82.     (*memPrintProc)(memPrintData, "Allocator not initialized yet.\n");
  83.     return;
  84.     }
  85.  
  86. #define VERBOSE 2
  87. #ifdef VERBOSE
  88.     (*memPrintProc)(memPrintData, "Small object allocator:\n");
  89.     for (i = 2; i < BIN_BUCKETS; i++) {
  90.     if ((memFreeLists[i] == (Address) NULL)
  91.         || (memFreeLists[i] == NOBIN)) {
  92.         continue;
  93.     }
  94.     (*memPrintProc)(memPrintData, "    %d bytes:", INDEX_TO_BLOCKSIZE(i));
  95.     j = 5;
  96.     for (ptr = memFreeLists[i]; ptr != (Address) NULL; 
  97.         ptr = (Address) GET_ADMIN(ptr)) {
  98.         if (j == 5) {
  99.         (*memPrintProc)(memPrintData, "\n    ");
  100.         j = 0;
  101.         } else {
  102.         j += 1;
  103.         }
  104.         (*memPrintProc)(memPrintData, "%12#x", ptr);
  105.     }
  106.     (*memPrintProc)(memPrintData, "\n");
  107.     }
  108. #endif VERBOSE
  109.  
  110.     (*memPrintProc)(memPrintData, "Large object allocator:\n");
  111.  
  112. #ifdef MEM_TRACE
  113.     (*memPrintProc)(memPrintData, "    Location   Orig. Size   State\n");
  114. #else
  115.     (*memPrintProc)(memPrintData, "    Location       Size     State\n");
  116. #endif MEM_TRACE
  117.  
  118.     for (ptr = memFirst; ptr != memLast; ptr += SIZE(GET_ADMIN(ptr))) {
  119.  
  120. #ifdef MEM_TRACE
  121.     (*memPrintProc)(memPrintData, "%12#x %10d", ptr, GET_ORIG_SIZE(ptr));
  122.     if (IS_DUMMY(GET_ADMIN(ptr))) {
  123.         (*memPrintProc)(memPrintData, "     Dummy\n");
  124.     } else if (IS_IN_USE(GET_ADMIN(ptr))) {
  125.         (*memPrintProc)(memPrintData, "     In use (PC=0x%x)\n", GET_PC(ptr));
  126. #else
  127.     (*memPrintProc)(memPrintData, "%12#x %10d", ptr, SIZE(GET_ADMIN(ptr)));
  128.     if (IS_DUMMY(GET_ADMIN(ptr))) {
  129.         (*memPrintProc)(memPrintData, "     Dummy\n");
  130.     } else if (IS_IN_USE(GET_ADMIN(ptr))) {
  131.         (*memPrintProc)(memPrintData, "     In use\n");
  132. #endif MEM_TRACE
  133.     } else {
  134.         (*memPrintProc)(memPrintData, "     Free\n");
  135.     }
  136.     }
  137.     UNLOCK_MONITOR;
  138. }
  139. @
  140.  
  141.  
  142. 1.2.1.1
  143. log
  144. @Initial branch for Sprite server.
  145. @
  146. text
  147. @d18 1
  148. a18 1
  149. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/Mem_PrintConfig.c,v 1.2 89/01/30 15:39:35 brent Exp $ SPRITE (Berkeley)";
  150. @
  151.  
  152.  
  153. 1.1
  154. log
  155. @Initial revision
  156. @
  157. text
  158. @d18 1
  159. a18 1
  160. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  161. d61 1
  162. a61 1
  163.     (*memPrintProc)(memPrintData, "    %d bytes:", i*4);
  164. @
  165.